package com.sm.li.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.*;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.sm.li.common.valid.anno.Regular;
import com.sm.li.common.valid.group.AddGroup;
import com.sm.li.common.valid.group.UpdateGroup;
import com.sm.li.entity.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.poi.ss.usermodel.FillPatternType;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.math.BigDecimal;
import java.net.URL;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author 李
 * @since 2021-06-26
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_admin")
@ApiModel(value = "Admin对象", description = "")
@ContentRowHeight(100)
@HeadRowHeight(40)
@ColumnWidth(40)
// 头背景设置成红色 IndexedColors.RED.getIndex()
//@HeadStyle(fillPatternType = FillPatternType.SOLID_FOREGROUND, fillForegroundColor = 10)
// 头字体设置成20
//@HeadFontStyle(fontHeightInPoints = 20)
// 内容的背景设置成绿色 IndexedColors.GREEN.getIndex()
//@ContentStyle(fillPatternType = FillPatternType.SOLID_FOREGROUND, fillForegroundColor = 17)
// 内容字体设置成20
@ContentFontStyle(fontHeightInPoints = 20)
public class Admin extends BaseEntity {

    @ExcelProperty(value = "员工账号")
    @ApiModelProperty(value = "用户登陆时的用户名")
    @NotBlank(message = "用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]{4,15}$", groups = {AddGroup.class, UpdateGroup.class})
    private String adminAccount;

    @ExcelIgnore
    @ApiModelProperty(value = "管理员登录密码")
    private String adminPassword;

    @ExcelProperty(value = "员工姓名")
    @NotBlank(message = "员工姓名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @ApiModelProperty(value = "管理员姓名")
    private String adminName;

    @ExcelIgnore
    @ApiModelProperty(value = "管理员性别 0：男   1：女  2：不清楚")
    @Regular(values = {0, 1, 2})
    private Integer gender;

    @ExcelProperty(value = "员工性别")
    private transient String sex;

    @ExcelProperty(value = "员工手机号")
    @NotBlank(message = "手机号码不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$", groups = {AddGroup.class, UpdateGroup.class})
    @ApiModelProperty(value = "手机号码")
    private String adminPhone;

    @ExcelProperty(value = "员工邮箱")
    @NotBlank(message = "员工邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Email(message = "邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
    @ApiModelProperty(value = "管理员邮箱")
    private String adminEmail;

    @ExcelIgnore
    @ApiModelProperty(value = "管理员头像")
    private String adminAvatar;

    @ExcelProperty(value = "员工头像")
    private transient URL  url;

    @ExcelIgnore
    @ApiModelProperty(value = "是否激活")
    private Boolean isActive;

    @ExcelIgnore
    @ApiModelProperty(value = "是否为超级管理员")
    private Boolean isSuperAdmin;

    @ExcelProperty(value = "员工薪资")
    @NotNull(message = "员工薪资不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @ApiModelProperty(value = "管理员薪资")
    private Double adminSalary;

    @ColumnWidth(60)
    @ExcelProperty(value = "员工住址")
    @NotBlank(message = "员工住址不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @ApiModelProperty(value = "员工住址")
    private String adminAddress;

    @ColumnWidth(60)
    @ExcelProperty(value = "员工身份证号")
    @NotBlank(message = "员工身份证号不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-8]|1[0-2])(0[1-9]|[12][0-9]|3[01])\\d{3}[0-9xX]$", groups = {AddGroup.class, UpdateGroup.class})
    @ApiModelProperty(value = "员工身份证号")
    private String adminCode;

    @ExcelIgnore
    private transient List<Long> roleIds;
}
